Adding file descriptor in template.
[and.git] / 591 - Box of bricks / Intentando ayudar / tarif.cpp
blob0c5cfdc39fa9e2e7e2a3bc1e12e82566beb2ced4
1 #include <stdio.h>
2 #include <assert.h>
4 int array[100];
6 int main(void)
9 int n, h,l_1,l_2,set=0,num_bricks=0,bricks_pwal,move=0;
11 for( ; ; )
13 scanf("%d", &n);
14 if(n==0)
16 return 0;
18 set++;
19 assert(n>=1 && n<=50);
21 /*will the set increase here or before :( */
22 for(l_1=0;l_1<n;l_1++)
24 scanf("%d", &h);
25 while(h<=0 || h>100)
27 scanf("%d",&h);
30 /*assert(ch=='@' || ch=='*');*/
31 array[l_1] = h;
32 num_bricks +=h;
35 if(num_bricks%n==0)
37 bricks_pwal = num_bricks/n;
39 for(l_2=0;l_2<n;l_2++)
41 if(bricks_pwal-array[l_2]>0)
43 move += bricks_pwal-array[l_2];
48 printf("Set #%d\n", set);
49 printf("The minimum number of moves is %d.\n\n", move);
51 move = 0;
52 num_bricks = 0;
56 /*return 0;*/